package main
import "fmt"

func main() {
    // 创建集合
    var countryCapitalMap map[string]string
    countryCapitalMap = make(map[string]string)

    // map插入key-value
    countryCapitalMap["France"] = "巴黎"
    countryCapitalMap["Italy"] = "罗马"
    countryCapitalMap["Japan"] = "东京"
    countryCapitalMap["India"] = "新德里"

    // 使用键输出
    for country := range countryCapitalMap {
        fmt.Println(country, "首都是", countryCapitalMap[country])
    }

    // 删除元素
    delete(countryCapitalMap, "India")

    // 查看元素在集合是否存在
    // capital, ok := countryCapitalMap["American"]
    capital, ok := countryCapitalMap["Japan"]

    if ok {
        fmt.Println("American的首都是", capital)
    } else {
        fmt.Println("American的首都不存在")
    }
}
